﻿using System.Web;
using System.Web.Http.Controllers;

namespace $safeprojectname$.Project.OData
{
    public class ODataFilter
    {
        public ODataFilter(HttpControllerContext context)
        {
            Where = ParseQuery(context, "$filter");
            Select = ParseQuery(context, "$select");
            OrderBy = ParseQuery(context, "$orderby");
            Skip = ParseQuery(context, "$skip");
            Take = ParseQuery(context, "$top");
            InlineCount = ParseQuery(context, "$inlinecount");
            Format = ParseQuery(context, "$format");
            Expand = ParseQuery(context, "$expand");
        }
        public string ParseQuery(HttpControllerContext context, string key)
        {
            var value = HttpUtility.ParseQueryString(context.Request.RequestUri.Query).Get(key);
            return value;
        }
        public string Select { get; set; }
        public string Where { get; set; }
        public string OrderBy { get; set; }
        public string Skip { get; set; }
        public string Take { get; set; }
        public string InlineCount { get; set; }
        public string Format { get; set; }
        public string Expand { get; set; }

    }
}